package com.zzq.consumer;

import com.zzq.mapper.MessageMapper;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Service;

@Slf4j
@Service
@RequiredArgsConstructor  // 自动生成包含 final 字段的构造器
@RocketMQMessageListener(
        consumerGroup = "${rocketmq.consumer.group}",
        topic = "${rocketmq-topic.inform}",
        selectorExpression = "INFORM_TOPIC"
)
public class InformConsumer implements RocketMQListener<String> {

    private final MessageMapper messageMapper;

    @Override
    public void onMessage(String notice) {
        // 处理接收到的通知
       log.info("收到通知: {}",notice);

        // 业务处理逻辑...
        messageMapper.pushMessage(notice);
    }
}